<?php
class City extends Eloquent
{
    public static $timestamps = false;

    public function districts()
    {
        return $this->has_many('District');
    }

    public static function items()
    {
        $results = array();
        foreach (static::all() as $city) {
            if ($city->districts()->count() > 0) {
                $results[] = $city;
            }
        }

        return $results;
    }

    public static function first()
    {
        $cities = static::items();
        if (count($cities) > 0) {
            return $cities[0];
        } else {
            return null;
        }
    }
}